package com.easy;

/**
 * Created by Lxk on 2020/1/18.
 */
public class Solution1290 {

    public int getDecimalValue(ListNode head) {
        int num = 0;
        if (head == null) {
            return num;
        }
        ListNode cur = head;

        while (cur != null) {
            num *= 2;
            if (cur.val == 1) {
                num += 1;
            }
            cur = cur.next;
        }
        return num;
    }

}
